package com.kyivmohyla.kma2.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.kyivmohyla.kma2.client.exception.DelistedException;
import com.kyivmohyla.kma2.shared.model.*;

import java.util.List;
import java.util.Map;

@RemoteServiceRelativePath("UserService")
public interface UserService extends RemoteService {

    void changePassword(String email) throws DelistedException;

    List<UIOrder> getOrdersByState(int[] state);

    List<UIOrder> getOrdersByStateAndDate(int[] states, String date);

    List<UIOrder> getOrdersByStateAndDateAndPosition(int[] states, String date, int position);

    List<UICustomer> getCustomerAllCustomers();

    List<UIEquipment> getEquipmentAllEquipment();

    List<UIHistory> getHistoryAllHistory();

    List<UIOrder> getOrderAllOrder();

    List<UIOrderServEquip> getOrderServEquipAllOrderServEquip();

    List<UIPosition> getPositionAllPosition();

    List<UIRefs> getRefsAllRefs();

    List<UIService> getServiceAllService();

    List<UIService> getServiceByOrderId(int id) throws DelistedException;

    List<UIEquipment> getEquipmentByOrderId(int id) throws DelistedException;

    List<UIStaff> getStaffAllStaffs();

    List<UIStaff> getAllEngineers();

    List<UIState> getStateAllState();

    UICustomer getCustomerById(int id) throws DelistedException;

    UICustomer getCustomerWithMaxId() throws DelistedException;

    UIOrder getOrderWithMaxId() throws DelistedException;

    void addCustomer(UICustomer customer) throws DelistedException;

    void updateCustomer(UICustomer customer) throws DelistedException;

    void addOrder(UIOrder order) throws DelistedException;

    void updateOrder(UIOrder order) throws DelistedException;

    void addNewObjectToReferenceBook(UIEquipment obj) throws DelistedException;

    void addNewObjectToReferenceBook(UIService obj) throws DelistedException;

    void deleteObjectsFromEquipmentRB(List<UIEquipment> objs) throws DelistedException;

    void deleteObjectsFromServiceRB(List<UIService> objs) throws DelistedException;

    void deleteOrder(UIOrder order) throws DelistedException;

    void deleteCustomer(UICustomer customer) throws DelistedException;

    List<UIHistory> getHistoryByOrderId(int id) throws DelistedException;

    void addHistory(UIHistory history) throws DelistedException;

    void addOrderServEquipList(List<UIOrderServEquip> orderServEquipList) throws DelistedException;

    void deleteOrderServEquipList(List<UIOrderServEquip> orderServEquipList) throws DelistedException;

    List<UIEquipment> deleteParentEquipmentList(List<UIEquipment> equipments) throws DelistedException;

    List<UIEquipment> deleteChildEquipmentList(List<UIEquipment> equipments) throws DelistedException;

    List<UIService> deleteParentServiceList(List<UIService> services) throws DelistedException;

    List<UIService> deleteChildServiceList(List<UIService> services) throws DelistedException;

    Map<UIOrder, Boolean> validateOrderSchedule(List<UIOrder> orders) throws DelistedException;

    void updateOrderList(List<UIOrder> orders) throws DelistedException;

    List<UIEquipment> getEquipmentByServicesList(List<UIService> services) throws DelistedException;

    UIEquipment getEquipmentById(int id) throws DelistedException;

    UIService getServiceById(int id) throws DelistedException;

    void addRefsList(List<UIRefs> refsList) throws DelistedException;

    void deleteRefsList(List<UIRefs> refsList) throws DelistedException;

    void sendMail(String recipient, String subject, String message);

    void updateEquipment(UIEquipment equipment) throws DelistedException;

    void updateService(UIService service) throws DelistedException;

    void deleteOrderServEquipByOrderId(int id) throws DelistedException;

    /**
     * Utility/Convenience class.
     * Use UserService.App.getInstance() to access static instance of UserServiceAsync
     */
    public static class App {
        private static final UserServiceAsync ourInstance = (UserServiceAsync) GWT.create(UserService.class);

        public static UserServiceAsync getInstance() {
            return ourInstance;
        }
    }
}
